package com.cwz.file.controller;


import com.cwz.api.entity.UserPath;
import com.cwz.core.result.R;
import com.cwz.file.model.UserPathVo;
import com.cwz.file.service.UserPathService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户文件目录表 前端控制器
 * </p>
 *
 * @author Wen
 * @since 2023-06-28
 */
@RestController
@RequestMapping("/file")
public class UserPathController {
	@Autowired
	private UserPathService userPathService;

	/**
	 * @Description: 新建文件夹
	 * @Author: Wen
	 * @param userPath:
	 * @return: com.cwz.core.result.R<java.lang.Void>
	 **/
	@PostMapping("/user-path")
	public R<Void> addUserPath(@Validated @RequestBody UserPath userPath) {
		return this.userPathService.addUserPath(userPath);
	}

	/**
	 * @Description: 编辑文件夹
	 * @Author: Wen
	 * @param userPath:
	 * @return: com.cwz.core.result.R<java.lang.Void>
	 **/
	@PutMapping("/user-path")
	public R<Void> updateUserPath(@Validated @RequestBody UserPath userPath) {
		return this.userPathService.updateUserPath(userPath);
	}

	/**
	 * @Description: 删除文件夹
	 * @Author: Wen
	 * @param pathId:
	 * @return: com.cwz.core.result.R<java.lang.Void>
	 **/
	@DeleteMapping("/user-path/{pathId}")
	public R<Void> deleteUserPath(@PathVariable Long pathId) {
		return this.userPathService.deleteUserPath(pathId);
	}

	/**
	 * @Description: 查询文件夹
	 * @Author: Wen
	 * @param userId:
	 * @return: com.cwz.core.result.R<java.util.List<com.cwz.file.model.UserPathVo>>
	 **/
	@GetMapping("/user-path/{userId}")
	public R<List<UserPathVo>> listUserPath(@PathVariable Long userId) {
		return this.userPathService.listUserPath(userId);
	}

}

